package com.school.fuyuan.business.mapper;

import com.school.fuyuan.business.model.po.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author zrhong
 * @version 1.0
 * @date 2019/3/26 21:06
 * @description
 */
@Mapper
public interface RoleMapper {
    @Select("select role_id roleId,role_name roleName from role")
    List<Role> getRoles();

    void add(Role role);

    void addRolePrivilege(@Param("roleId") String roleId, @Param("privileges") List<String> privileges);

    @Delete("delete from role where role_id=#{roleId}")
    void deleteRole(String roleId);

    @Delete("delete from role_privilege where role_id=#{roleId}")
    void deleteRolePrivilege(String roleId);

    List<Integer> getPrivileges(List<Integer> roleIds);

    @Select("select role_id from user_role where user_id=#{userId}")
    List<Integer> getUserRole(String userId);
}
